﻿using MediatR;
using Sale.Api.Application.工单.Command.Client;
using Sale.Domain;
using Sale.ErrorCode;
using Sale.Infrastructure.Interface;
using SqlSugar;

namespace Sale.Api.Application.工单.Handler.Client
{
    public class FanTianClienHandler : IRequestHandler<FanTianClienCommand, ApiResult<List<ClientModel>>>
    {
        private readonly IBaseRepository<ClientModel> clientRepo;
        private readonly ILogger<FanTianClienHandler> logger;

        public FanTianClienHandler(IBaseRepository<ClientModel> clientRepo,ILogger<FanTianClienHandler> logger)
        {
            this.clientRepo = clientRepo;
            this.logger = logger;
        }


        public Task<ApiResult<List<ClientModel>>> Handle(FanTianClienCommand request, CancellationToken cancellationToken)
        {
            ApiResult<List<ClientModel>> result = new ApiResult<List<ClientModel>>();
            var client=clientRepo.GetAll().Where(x=>x.ClientId==request.ClientId).ToList();
            result.Code = ApiEnum.OK;
            result.Data =client;
            result.Msg = "反填成功";
            return Task.FromResult(result);
        }
    }
}
